var t, e, a, n = require("../@babel/runtime/helpers/defineProperty"), s = getApp(), o = require("../js/md5.js"), i = require("../js/aesUtil.js"), l = "https://xcweb.caict.ac.cn:8088";
console.log("aaaaa:"+a);
function u(a) {
    wx.showLoading({
        title: "加载中",
        mask: !0
    });
    var n = h(), s = o.hexMD5(e + n);
    wx.request({
        url: l + "/weixin/sendSecurityMsg",
        method: "post",
        data: {
            phone: a,
            queryId: r(),
            sendTime: n,
            secert: s
        },
        success: function(e) {
            wx.hideLoading(), "1" === e.data.status ? "00" === e.data.code && (t.setData({
                pwdValue: "",
                pwdFocus: !0
            }), wx.showToast({
                title: e.data.result,
                icon: "none"
            })) : "2" === e.data.status ? "32" === e.data.code ? wx.showModal({
                title: "提示",
                content: " 您的验证码仍在有效期内",
                showCancel: !1
            }) : wx.showModal({
                title: "提示",
                content: "发送短信失败",
                showCancel: !1
            }) : w();
        },
        fail: function(t) {
            wx.hideLoading(), w();
        },
        complete: function(t) {}
    });
}

function d(t, n, u) {
//    wx.showLoading({
//        title: "加载中",
//        mask: !0
//    });

    var d = h(), c = o.hexMD5(e + d);
    var n="K1eJX6qvfkcoBNRXE1Vd/r6M6kq37twh0iM4HyAQs2R/cA9eJAAPf8Ec9/rSPhNs";
//    var a = "15700985898"
    // var t ={
    //          "status": "1",
    //          "code": "00",
    //          "errorDesc": "请求成功",
    //          "result": {
    //            "color": "green",
    //            "phone": "157****5898",
    //            "time": "2021.11.1217:25:59",
    //            "message": "K1eJX6qvfkcoBNRXE1Vd/r6M6kq37twh0iM4HyAQs2R/cA9eJAAPf8Ec9/rSPhNs"
    //          },
    //          "queryId": "WWBTAaVYe38MESrRkK6qMAJEVFIyQLPn"
    //        };

      var e,n;
    //   e = t, n = e.result.message;
      console.log(n);

    console.log("a:"+a);
    console.log("decrypt:"+i.Decrypt(a, n));

    var teststr = {
        "openId": "oI_WL5QzhMv7gtTUOxDailI5OIbg",
        "queryId": "P1aW2Qd3scqe51c1HqoltxyQxpQ1D1FI",
        "sendTime": "2021-11-25 11:37:50",
        "secert": "481d603dd9fc7386e2930732de9cb49d"
      };

    wx.request({
        url: l + "/weixin/query_v6",
        method: "post",
        data: {
            phone: t,
            verification: n,
            queryId: r(),
            openId: u,
            sendTime: d,
            secert: c
        },
        // data:{
        //     "openId": "oI_WL5QzhMv7gtTUOxDailI5OIbg",
        //     "queryId": "P1aW2Qd3scqe51c1HqoltxyQxpQ1D1FI",
        //     "sendTime": d,
        //     "secert": c
        //   },
        success: function(t) {
            console.log("查看调接口时的a："+a);
            var n="K1eJX6qvfkcoBNRXE1Vd/r6M6kq37twh0iM4HyAQs2R/cA9eJAAPf8Ec9/rSPhNs";
            console.log("decrypt:"+i.Decrypt(a, n));
            var e, n;
            wx.hideLoading(), "1" === t.data.status ? (g(t.data), e = t.data, n = e.result.message,
            e.result.message = i.Decrypt(a, n), "14" === e.code ? (s.globalData.result = JSON.stringify(e.result),
            wx.navigateTo({
                url: "/pages/result3/result3"
            })) : "00" === e.code ? "green" === e.result.color ? (s.globalData.result = JSON.stringify(e.result),
            wx.navigateTo({
                url: "/pages/result/result"
            })) : "yellow" === e.result.color ? (s.globalData.result = JSON.stringify(e.result),
            wx.navigateTo({
                url: "/pages/result2/result2"
            })) : "red" === e.result.color && (s.globalData.result = JSON.stringify(e.result),
            wx.navigateTo({
                url: "/pages/result1/result1"
            })) : w()) : "2" === t.data.status ? wx.showModal({
                title: "提示",
                content: t.data.errorDesc,
                showCancel: !1
            }) : w();
        },
        fail: function(t) {
            var e, n;
            console.log("查看调接口时的a："+a)
                        wx.hideLoading(), "1" === t.data.status ? (g(t.data), e = t.data, n = e.result.message,
                        e.result.message = i.Decrypt(a, n), "14" === e.code ? (s.globalData.result = JSON.stringify(e.result),
                        wx.navigateTo({
                            url: "/pages/result3/result3"
                        })) : "00" === e.code ? "green" === e.result.color ? (s.globalData.result = JSON.stringify(e.result),
                        wx.navigateTo({
                            url: "/pages/result/result"
                        })) : "yellow" === e.result.color ? (s.globalData.result = JSON.stringify(e.result),
                        wx.navigateTo({
                            url: "/pages/result2/result2"
                        })) : "red" === e.result.color && (s.globalData.result = JSON.stringify(e.result),
                        wx.navigateTo({
                            url: "/pages/result1/result1"
                        })) : w()) : "2" === t.data.status ? wx.showModal({
                            title: "提示",
                            content: t.data.errorDesc,
                            showCancel: !1
                        }) : w();
        },
        complete: function(t) {console.log("查看调接口时的a："+a);}
    });
}

function r() {
    for (var t = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ], e = "", a = 0; a < 32; a++) {
        e += t[parseInt(61 * Math.random())];
    }
    return e;
}

function c(t) {
    return t < 10 ? "0" + t : t + "";
}

function h() {
    var t = new Date();
    return t.getFullYear() + "-" + c(t.getMonth() + 1) + "-" + c(t.getDate()) + " " + c(t.getHours()) + ":" + c(t.getMinutes()) + ":" + c(t.getSeconds());
}

function g(t) {}

function w() {
    wx.showModal({
        title: "提示",
        content: "当前网络不稳定，查询结果可能返回较慢。可直接发送短信CXMYD到所属运营商(电信10001/移动10086/联通10010)进行查询。",
        showCancel: !1,
        confirmText: "我知道了"
    });
}

Page({
    data: {
        getSmsColor: "#AAAAAA",
        phoneDel: "hidden",
        pwdDel: "hidden",
        checkBoxItems: [ {
            name: "0",
            value: ""
        } ],
        btnBg: "#66AFFF",
        second: 60,
        phoneNum: "",
        pwdNum: "",
        send: !0,
        sent: !1,
        canSubmit: !1,
        phoneNumValue: "",
        pwdValue: "",
        phoneNumFocus: !1,
        pwdFocus: !1,
        openId: "",
        message: {},
        qdDialog: {
            show: !1,
            phone: "",
            title: "",
            checked: !1,
            buttonsShowVertical: !0,
            showinput: !1,
            imgsrc: "../images/img_cards@3x.png",
            disabled: !0,
            buttons: [ {
                text: "取消",
                color: "#ff8427",
                types: 1
            }, {
                text: "确定",
                color: "#ff8427",
                types: 2
            } ]
        },
        banners: [ {
            index: "1",
            style1: "display:none",
            style2: "",
            img: "yztc.jpg"
        }, {
            index: "2",
            style1: "",
            style2: "display:none",
            img: "xty",
            text: "中国信通院\n国家高端专业智库·产业创新发展平台"
        }, {
            index: "3",
            style1: "",
            style2: "display:none",
            img: "yd",
            text: "下载中国移动App\n更多服务办理"
        }, {
            index: "4",
            style1: "",
            style2: "display:none",
            img: "lt",
            text: "关注联通大数据公众号，随需查询\n更多大数据服务与您共抗疫情"
        }, {
            index: "5",
            style1: "",
            style2: "display:none",
            img: "dx",
            text: "用电信APP\n充值查询更方便"
        } ],
        banner_dots: [ 1, 2, 2, 2, 2 ],
        banner_interval: 6e3,
        banner_current: 0,
        SMSCheckBox: !1
    },
    openDialog: function() {
        var t = this.data.qdDialog;
        t.show = !0, t.content = "这是是内容", t.disabled = !0, t.buttons = [ {
            text: "按钮",
            color: "#ff8427",
            types: 2
        } ], this.setData({
            qdDialog: t
        });
    },
    closeDialog: function() {
        var t = this.data.qdDialog;
        t.show = !1, t.disabled = !1, t.buttons = [], this.setData({
            qdDialog: t
        });
    },
    fastquery: function() {
        var e = this.getCacheInfo();
        "" == e || null == e || null == e ? (wx.showLoading({
            title: "加载中",
            mask: !0
        }), this.doFastQuery()) : wx.showModal({
            title: "提示",
            content: "使用缓存数据",
            showCancel: !1,
            confirmText: "我知道了",
            success: function(a) {
                a.confirm && (t.data.message = e, t.manageFastqueryResult());
            }
        });
    },
    doFastQuery: function() {
        var a = h(), n = o.hexMD5(e + a);
        console.log("doFastQuery  a:"+a)
        wx.request({
            url: l + "/weixin/query_v6",
            method: "post",
            data: {
                openId: this.data.openId,
                queryId: r(),
                sendTime: a,
                secert: n
            },
            success: function(e) {
                "1" === e.data.status ? (t.data.message = e.data, e.data, t.manageFastqueryResult()) : (wx.hideLoading(), 
                "2" === e.data.status ? wx.showModal({
                    title: "提示",
                    content: e.data.errorDesc,
                    showCancel: !1
                }) : w());
            },
            fail: function(t) {
                wx.hideLoading(), w();
            },
            complete: function(t) {}
        });
    },
    manageFastqueryResult: function() {
        var e = t.data.message, n = e.result.message;
        console.log("manageFastqueryResult a:"+a)
        e.result.message = i.Decrypt(a, n), "14" === e.code ? (s.globalData.result = JSON.stringify(e.result), 
        wx.navigateTo({
            url: "/pages/result3/result3"
        })) : "00" === e.code && ("green" === e.result.color ? (s.globalData.result = JSON.stringify(e.result), 
        wx.navigateTo({
            url: "/pages/result/result"
        })) : "yellow" === e.result.color ? (s.globalData.result = JSON.stringify(e.result), 
        wx.navigateTo({
            url: "/pages/result2/result2"
        })) : "red" === e.result.color && (s.globalData.result = JSON.stringify(e.result), 
        wx.navigateTo({
            url: "/pages/result1/result1"
        }))), this.closeDialog(), wx.hideLoading();
    },
    clear: function() {
        var t = getCurrentPages();
        t[t.length - 1].data.checkBoxItems;
        this.setData({
            send: !0,
            sent: !1,
            pwdValue: ""
        });
    },
    onLoad: function(e) {
        t = this;
    },
    onReady: function() {},
    onShow: function() {
       var o;
    //    wx.showLoading({
    //        title: "加载中",
    //        mask: !0
    //    }), 
       this.setData((n(o = {}, "qdDialog.disabled", !0), n(o, "qdDialog.checked", !1),
       n(o, "btnBg", "#66AFFF"), n(o, "canSubmit", !1), n(o, "SMSCheckBox", !1), n(o, "banner_current", 0),
       o)), s.globalData.result = "", wx.cloud.callFunction({
           name: "login",
           data: {},
           success: function(n) {
               var s;
               console.log("n:"+n);
               t.data.openId = n.result.openid, e = n.result.param1, a = n.result.param2, wx.hideLoading(),
               console.log("a:"+a);
               s = n.result.openid, wx.request({
                   url: l + "/weixin/check",
                   method: "post",
                   data: {
                       openId: s,
                       queryId: r()
                   },
                   success: function(e) {
                       "1" === e.data.status && (t.data.qdDialog.phone = e.data.result.phone, t.openDialog());
                   },
                   fail: function(t) {},
                   complete: function(t) {}
               });
           },
           fail: function(t) {
               w();
           }
       });
    },
    onHide: function() {
        this.closeDialog();
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onPhoneNumInput: function(t) {
        11 == t.detail.value.length ? this.setData({
            phoneNum: t.detail.value,
            getSmsColor: "#007AFF"
        }) : this.setData({
            phoneNum: "",
            getSmsColor: "#aaaaaa"
        });
    },
    onPhoneNumInputFocus: function() {
        this.setData({
            phoneDel: "visible"
        });
    },
    onPhoneNumInputBlur: function() {
        this.setData({
            phoneDel: "hidden"
        });
    },
    onPwdInput: function(t) {
        this.setData({
            pwdNum: t.detail.value
        });
    },
    onPwdInputFocus: function() {
        this.setData({
            pwdDel: "visible"
        });
    },
    onPwdInputBlur: function() {
        this.setData({
            pwdDel: "hidden"
        });
    },
    checkboxChange: function(t) {
        0 == t.detail.value && this.setData({
            btnBg: "#007AFF",
            canSubmit: !0
        }), "" == t.detail.value && this.setData({
            btnBg: "#66AFFF",
            canSubmit: !1
        });
    },
    sendSMS: function() {
        "" != this.data.phoneNum && (u(this.data.phoneNum), this.setData({
            sent: !0,
            send: !1
        }), this.timer());
    },
    timer: function() {
        var t = this;
        new Promise(function(e, a) {
            var n = setInterval(function() {
                t.setData({
                    second: t.data.second - 1
                }), t.data.second <= 0 && (t.setData({
                    second: 60,
                    sent: !1,
                    send: !0
                }), e(n));
            }, 1e3);
        }).then(function(t) {
            clearInterval(t);
        });
    },
    btnSubmit: function() {
//        this.data.phoneNum.length < 11 ? wx.showModal({
//            title: "提示",
//            content: "请输入正确的手机号码",
//            showCancel: !1
//        }) : this.data.pwdNum.length < 6 ? wx.showModal({
//            title: "提示",
//            content: "请输入正确的验证码",
//            showCancel: !1
//        }) : this.data.canSubmit ? d(this.data.phoneNum, this.data.pwdNum, this.data.openId) : wx.showModal({
//            title: "提示",
//            content: "请同意协议",
//            showCancel: !1
//        });
        d(this.data.phoneNum, this.data.pwdNum, this.data.openId)
    },
    delPhoneNum: function() {
        this.setData({
            phoneNumValue: "",
            phoneNumFocus: !0
        });
    },
    delPwd: function() {
        this.setData({
            pwdValue: "",
            pwdFocus: !0
        });
    },
    testssss: function() {},
    dialogCheckboxChange: function(t) {
        var e = 0 === t.detail.value.length;
        this.setData(n({}, "qdDialog.disabled", e));
    },
    bannerChange: function(t) {
        0 == t.detail.current ? this.setData({
            banner_interval: 6e3
        }) : this.setData({
            banner_interval: 3e3
        });
        for (var e = new Array(), a = 0; a < this.data.banner_dots.length; a++) t.detail.current == a ? e[a] = 1 : e[a] = 2;
        this.setData({
            banner_dots: [ e[0], e[1], e[2], e[3], e[4] ]
        });
    },
    callNum: function(t) {
        var e = t.currentTarget.dataset.num;
        wx.showActionSheet({
            itemList: [ "呼叫：" + e ],
            success: function(t) {
                wx.makePhoneCall({
                    phoneNumber: e
                });
            }
        });
    },
    openDes: function() {
        wx.navigateTo({
            url: "/pages/des/des"
        });
    },
    getCacheInfo: function() {
        return "";
    },
    changeCheckbox: function() {
        this.data.SMSCheckBox ? this.setData({
            btnBg: "#66AFFF",
            canSubmit: !1,
            SMSCheckBox: !1
        }) : this.setData({
            btnBg: "#007AFF",
            canSubmit: !0,
            SMSCheckBox: !0
        });
    },
    dialogChangeCheckbox: function() {
        var t, e;
        this.data.qdDialog.checked ? this.setData((n(t = {}, "qdDialog.disabled", !0), n(t, "qdDialog.checked", !1), 
        t)) : this.setData((n(e = {}, "qdDialog.disabled", !1), n(e, "qdDialog.checked", !0), 
        e));
    },
    yztcClick: function() {
        wx.navigateTo({
            url: "/pages/webview/webview"
        });
    }
});